//
//  WBN_FM_DetailView.m
//  GoodManNews
//
//  Created by 王博男 on 16/1/12.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "WBN_FM_DetailView.h"
#import "Masonry.h"

@implementation WBN_FM_DetailView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self createView];
    }
    return self;
}

- (void)layoutSubviews
{
    [self.imageV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self).offset(10);
        make.left.equalTo(self).offset(20);
        make.bottom.equalTo(self).offset(-10);
        make.width.equalTo(@60);
        
    }];
    
    
    [self.titleL mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.imageV.mas_top);
        make.left.equalTo(self.imageV.mas_right).with.offset(10);
        make.height.equalTo(@35);
        make.right.equalTo(self.mas_right).with.offset(-80);
        
    }];
    
    
    [self.contentL mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.titleL.mas_bottom);
        make.bottom.equalTo(self.mas_bottom).offset(-10);
        make.left.equalTo(self.titleL.mas_left);
        make.right.equalTo(self.titleL.mas_right);
        
    }];

    
    [self.button mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.contentL.mas_top).with.offset(- 5);
        make.left.equalTo(self.contentL.mas_right).with.offset(10);
        make.right.equalTo(self).offset(-10);
        make.bottom.equalTo(self).offset(-10);
        
    }];
}

 -(void)createView
{
    self.imageV = [UIImageView new];
    [self addSubview:self.imageV];
    
    
    self.titleL = [UILabel new];
    self.titleL.font = [UIFont systemFontOfSize:15];
    self.titleL.numberOfLines = 0;
    [self addSubview:self.titleL];
    
    
    self.contentL = [UILabel new];
    self.contentL.font = [UIFont systemFontOfSize:13];
    self.contentL.textColor = [UIColor lightGrayColor];
    [self addSubview:self.contentL];
    
    
    self.button = [UIButton buttonWithType:UIButtonTypeCustom];
    self.button.layer.cornerRadius = 15;
    self.button.layer.borderColor = [[UIColor lightGrayColor] CGColor];
    self.button.layer.borderWidth = 1;
    [self.button setTitle:@"详情" forState:UIControlStateNormal];
    [self.button setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    self.button.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.button addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.button];
}

- (void)buttonAction
{
    [self.delegate didCleckButton];
}

@end
